Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

138
Views
TensorFlowJS dice (Error: tamaño de textura solicitado [4327x4328] mayor que el máximo de WebGL en este navegador/GPU [4096x4096])

Cuando intento usar model.predict(tensor) para obtener un resultado del modelo, aparece el error indicado en el título. Sé que el tamaño de la textura de WebGL es una limitación de hardware que no se puede superar, por lo que me preguntaba si hay alguna forma de reducir el tamaño de la textura de un modelo de tensorflow o de alguna manera hacerlo en tensorflowjs. Intenté usar el backend de Web Assembly, pero no funciona muy bien para mi causa de uso.

¿Hay algún indicador que pueda usar para administrar el tamaño de la textura de mi modelo?

Gracias de antemano, y cualquier ayuda sería apreciada. A continuación se muestra mi código tensorflowjs.

 import { Dimensions } from 'react-native'; import * as ImageManipulator from 'expo-image-manipulator'; import * as tf from '@tensorflow/tfjs'; import { bundleResourceIO, decodeJpeg } from '@tensorflow/tfjs-react-native'; import { Base64Binary } from '../utils/b64'; import { image } from '@tensorflow/tfjs'; import * as FileSystem from 'expo-file-system'; const results = ['Not Melanoma', 'Melanoma']; const transformImageToTensor = async (uri) => { //.ts: const transformImageToTensor = async (uri:string):Promise<tf.Tensor>=>{ //read the image as base64 const img64 = await FileSystem.readAsStringAsync(uri, { encoding: FileSystem.EncodingType.Base64, }); const imgBuffer = tf.util.encodeString(img64, 'base64').buffer; const raw = new Uint8Array(imgBuffer); let imgTensor = decodeJpeg(raw); const scalar = tf.scalar(255); //resize the image imgTensor = tf.image.resizeNearestNeighbor(imgTensor, [300, 300]); //normalize; if a normalization layer is in the model, this step can be skipped const tensorScaled = imgTensor.div(scalar); //final shape of the rensor const img = tf.reshape(tensorScaled, [-1, 50, 50, 1]); return img; }; const predict = async (model, tensor) => { const output = await model.predict(tensor); return output.dataSync(); }; export const process = async (image, setDiagnosis, setLoading) => { console.log('inside process btw'); await tf.ready(); const modelJSON = require('../assets/models/model.json'); const modelWeights = require('../assets/models/group1-shard1of1.bin'); const model = await tf.loadLayersModel( bundleResourceIO(modelJSON, modelWeights) ); console.log('model loaded'); const tensor = await transformImageToTensor(image); console.log('converted to tensor'); const prediction = await predict(model, tensor); console.log('converted to tensor and prediction happened'); const highestPrediction = prediction.indexOf( Math.max.apply(null, prediction) ); console.log(highestPrediction); setDiagnosis(results[highestPrediction]); setLoading(false); };
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!